package prototype

type CardType int

const (
	BaseCardType CardType = iota
	CustomCardType
)

// PrototypeManager 原型管理器(注册和获取原型)
type PrototypeManager struct {
	prototypes map[CardType]ProductCard
}

func NewPrototypeManager() *PrototypeManager {
	return &PrototypeManager{
		prototypes: make(map[CardType]ProductCard),
	}
}

// RegisterPrototype 注册原型
func (pm *PrototypeManager) Register(cardType CardType, card ProductCard) {
	pm.prototypes[cardType] = card
}

// GetPrototype 获取原型
func (pm *PrototypeManager) Get(cardType CardType) ProductCard {
	if v, ok := pm.prototypes[cardType]; ok {
		return v.Clone()
	}
	return nil
}
